package Io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
/**
 * 读取文本文件
 */
public class ReadString {
    public static void main(String[] args) throws IOException {
        File file = new File("fos.txt");
        FileInputStream fis = new FileInputStream(file);
        long len = file.length();                    //获取文件大小
        byte[] by = new byte[(int)len];              //读取文件字节长度
        fis.read(by);                                //一次性读完
        String s = new String(by, StandardCharsets.UTF_8);
        System.out.println(s);
        fis.close();
    }
}
